/*
 * Thread.h
 *
 *  Created on: 2009/12/09
 *      Author: Peter.Song
 */
#ifndef COMMON_DEFINES_H_
#define COMMON_DEFINES_H_

#include <iostream>

using namespace std;

#if __WORDSIZE == 64
typedef long long		intptr;
#else
typedef unsigned int	intptr;
#endif

typedef intptr npINTPOINTER;


const std::size_t BIN = sizeof(npINTPOINTER); //bytes
const std::size_t CHUNK_SET_NUM = 100;

enum EN_BIN_SIZE_INDEX{
	EN_BIN4 = 0,
	EN_BIN8,
	EN_BIN16,
	EN_BIN32,
	EN_BIN64,
	EN_BIN128,
	EN_BIN256,

	EN_BIN_INDEX_MAX,
};

//-- BIN * i is the chunk size per chunk list(i)
const std::size_t BIN_SIZE[EN_BIN_INDEX_MAX] = {
		BIN * 1, BIN * 2,
		BIN * 4, BIN * 8,
		BIN * 16,BIN * 32,
		BIN * 64,
};

const std::size_t BLOCK_SIZE = CHUNK_SET_NUM * BIN * 64;

#define BLOCK_CHUNK_SIZE(index) (BLOCK_SIZE / BIN_SIZE[index])

typedef struct _MemBlock{
	char data[BLOCK_SIZE];
	_MemBlock* next;
}MemBlock;

#endif //COMMON_DEFINES_H_
